<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:29:"./themes/admin/dp/course.html";i:1746413787;s:51:"/lysoo/syzth.lysoo.com/syzth/themes/admin/base.html";i:1741049647;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">课程管理</li>
                <li class=""><a href="<?php echo url('admin/dp/course_add'); ?>">添加课程</a></li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" action="">
                        <div class="layui-form-item" style="margin-bottom: 10px;">
    <div class="layui-inline">
        <input type="text" name="name" placeholder="请输入课程名称" value="<?php echo $name; ?>" class="layui-input">
    </div>
    <div class="layui-inline" style="margin-left: 10px;">
    <a href="<?php echo url('admin/dp/export_course'); ?>" class="layui-btn layui-btn-normal">导出课程</a>
</div>
    <div class="layui-inline">
        <select name="category_id">
            <option value="">全部分类</option>
            <?php if(is_array($categories) || $categories instanceof \think\Collection || $categories instanceof \think\Paginator): if( count($categories)==0 ) : echo "" ;else: foreach($categories as $key=>$cat): ?>
                <option value="<?php echo $cat['id']; ?>" <?php if($cat['id'] == $category_id): ?>selected<?php endif; ?>><?php echo $cat['name']; ?></option>
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </select>
    </div>
    <div class="layui-inline">
    <select name="status">
        <option value="">全部状态</option>
        <option value="0" <?php if($status==='0'): ?>selected<?php endif; ?>>未上课</option>
        <option value="1" <?php if($status==='1'): ?>selected<?php endif; ?>>已上课</option>
        <option value="2" <?php if($status==='2'): ?>selected<?php endif; ?>>已取消</option>
    </select>
</div>
    <div class="layui-inline">
        <button class="layui-btn" lay-submit>搜索</button>
    </div>
</div>
                        <table class="layui-table" lay-size="sm">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>课程名</th>
                                <th>分类</th>
                                <th>课程专家</th>
                                <th>课程时间</th>
                                <th>课程介绍</th>
                                 <th>最大预约人数</th>
                                  <th>已预约人数</th>
                                  <th>状态</th>
                                <th style="width: 120px;">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if(is_array($courses) || $courses instanceof \think\Collection || $courses instanceof \think\Paginator): if( count($courses)==0 ) : echo "" ;else: foreach($courses as $key=>$vo): ?>
                            <tr>
                                <td><?php echo $vo['id']; ?></td>
                                <td><?php echo $vo['name']; ?></td>
                                <td><?php echo $vo['category_name']; ?></td>
                                <td><?php echo $vo['expert_name']; ?></td>
                                <td><?php echo $vo['course_time']; ?></td>
                                <td><?php echo $vo['desc']; ?></td>
                                 <td><?php echo $vo['max_number']; ?></td>
                                <td><?php echo $vo['booked']; ?></td>
                                <td>
    <?php if($vo['status'] == 0): ?>
        <span style="color: #1E9FFF;">未上课</span>
    <?php elseif($vo['status'] == 1): ?>
        <span style="color: green;">已上课</span>
    <?php elseif($vo['status'] == 2): ?>
        <span style="color: gray;">已取消</span>
    <?php endif; ?>
</td>
                                <td>
                                    <div class="layui-btn-group">
                                        <a href="<?php echo url('admin/dp/course_edit',['id'=>$vo['id']]); ?>" class="layui-btn layui-btn-sm" title="编辑"><i class="layui-icon">&#xe642;</i></a>
                                        <!--<a href="<?php echo url('admin/dp/course_delete',['id'=>$vo['id']]); ?>" class="layui-btn layui-btn-sm ajax-delete" title="删除"><i class="layui-icon">&#xe640;</i></a>-->
                                        <a href="<?php echo url('admin/dp/course_cancel',['id'=>$vo['id']]); ?>" class="layui-btn layui-btn-sm ajax-cancel" title="取消课程"><i class="layui-icon">&#x1006;</i></a>

                                    </div>
                                </td>
                            </tr>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
    layui.use(['layer','form'], function(){
        var $ = layui.jquery, layer = layui.layer;
        var form = layui.form;
        $('.ajax-cancel').on('click', function () {
    var _href = $(this).attr('href');
    layer.open({
        shade: false,
        content: '确定取消该课程？',
        btn: ['确定', '取消'],
        yes: function (index) {
            $.ajax({
                url: _href,
                type: "get",
                success: function (info) {
                    if (info.code === 1) {
                        window.location.reload()
                    }
                    layer.msg(info.msg);
                }
            });
            layer.close(index);
        }
    });

    return false;
});
        $('.ajax-delete').on('click', function () {
            var _href = $(this).attr('href');
            layer.open({
                shade: false,
                content: '确定删除？',
                btn: ['确定', '取消'],
                yes: function (index) {
                    $.ajax({
                        url: _href,
                        type: "get",
                        success: function (info) {
                            if (info.code === 1) {
                                window.location.reload()
                            }
                            layer.msg(info.msg);
                        }
                    });
                    layer.close(index);
                }
            });

            return false;
        });
    });
</script>

<!--页面JS脚本-->
</body>
</html>

